package development.group;

import state.GameForm;
import state.Graphics;
import state.GroupForm;
import state.component.MultiTab;
import state.util.Hashtable;
import development.Constants;
import development.DrawUtils;
import development.FrmNapXu;
import development.Global;
import development.app.Frm18plus;
import development.app.FrmCuaHang;

public class FrmGroupCuaHang18PlusNapXu extends GroupForm {
  private MultiTab multiTab;
  private static GameForm singleton;
  public static GameForm backForm;
  
  public static GameForm instance() {
    if (singleton == null) {
      singleton = new FrmGroupCuaHang18PlusNapXu();
    }
    return singleton;
  }
  
  public void init(Hashtable parameters) {
    multiTab = new MultiTab(this, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT);
    multiTab.addTab("Cửa hàng", FrmCuaHang.instance(), parameters);
    multiTab.addTab("18+", Frm18plus.instance(), parameters);
    multiTab.addTab("Nạp xu", FrmNapXu.instance(), parameters);
    multiTab.setStyle(Constants.MULTI_TAB_STYLE);
    multiTab.selectTab(0);
    ((FrmCuaHang) FrmCuaHang.instance()).getGridMenu().setNextTabWhenEndRow(multiTab);
  }
  
  public static void setTab(int index) {
    FrmGroupCuaHang18PlusNapXu frmFriendAndTop = (FrmGroupCuaHang18PlusNapXu) FrmGroupCuaHang18PlusNapXu.instance();
    MultiTab multiTab = frmFriendAndTop.getMultiTab();
    if (multiTab != null) {
      multiTab.selectTab(index);
    }
  }
  
  public MultiTab getMultiTab() {
    return multiTab;
  }
  
  public void draw(Graphics g) {
    DrawUtils.drawBackground(g);
  }
  
  public void goBack() {
    Global.nextState(FrmGroupMenu.instance(), null);
  }
  
  public void destroy() {
    multiTab.detroy();
    multiTab = null;
    FrmCuaHang.instance().detroyAll();
    Frm18plus.instance().detroyAll();
    FrmNapXu.instance().detroyAll();
  }
}
